package com.integrador.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Util {
	
	public static boolean isBlankOrNull(String parameter) {
		if(parameter == null || parameter.isEmpty()){
			return true;
		}
		return false;
	}

	public static boolean isNotBlankOrNull(String parameter) {
		return !isBlankOrNull(parameter);
	}
	
	public static boolean isNull(Object object){
		if(object == null){
			return true;
		}
		return false;
	}

	public static boolean isNotNull(Object object){
		return !isNull(object);
	}
	
	public static Integer convertStringToInteger(String number){
		Integer numberInteger = null;
		try {
			numberInteger = Integer.valueOf(number);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		return numberInteger;
		
	}

	public static Long convertStringToLong(String number){
		Long numberLong = null;
		try {
			numberLong = Long.valueOf(number);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		return numberLong;
		
	}
	
	public static Date createSimpleDate(String date, String formatDate){
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat(formatDate);
		Date newDate = null;
		try {
			 newDate = simpleDateFormat.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
		return newDate;
	}

}
